Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Programming > Formula Language > Indenting formula language for better readability
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Indenting formula language for better readability

Proposal for indentation rules in nested commands to drastically improve readability
Community articleIndenting formula language for better readability
Added by ~Anita Froaploplen | Edited by ~Anita Froaploplen on January 18, 2012 | Version 5
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
Proposal for indentation rules in nested commands to drastically improve readability
Tags: Formula language, layout
ShowTable of Contents
HideTable of Contents
  • 1 Introduction
  • 2 Proposed coding rules
  • 3 Examples
  • 4 Conclusion

Introduction

Formula language programming has a tendency to create horrificly unreadable formula code. The designer is not very helpful in (semi) automatic indentation adding to that issue. Still, it is still often the most powerful, fastest and most security abiding way of getting things done. Part of the issue is legacy: in older versions it was not possible to break lines or use tabs. Later on, more nested commands were added (i.e. @For) adding to deep and often unreadable nesting.

 

Proposed coding rules

This document proposes simple coding style rules for @Formula language. It is incomplete and informally written.
 

  1. Every opening parenthesis of a control statement (like @If, @For, @Do, etc) is followed by a newline and a new indentation level;
  2. Indentation is done through the use of tabs;
  3. The corresponding closing parenthesis is on a new line and outdented, usually, but not always followed by the closing semicolon. Caveat: no semicolon on the previous line!;
  4. Special case for @If: all even arguments get their own extra indentation, making them easily identifiable to their corresponding condition;
  5. Special case for @For: keep arguments 1, 2 and 3 on one line, as those are controlling the loop.

Examples

	@If(
	    choice = 1;
	       @Setfield("Approved";"Yes");
	    choice = 2;
	       @Setfield("Approved";"No");
	    @Return("")
	);
	



	@If(
	   choice = 1;
	      @Do(
	          @Setfield("Approved";"Yes");
	          @Setfield("ApprovedBy";@Username)
	      );
	   @Return("")
	);
	



	@For(
	    n := 1; n <= 10; n++;
	       result := result + array [n]
	);

	

 

Conclusion

While this coding style created far more lines than free coding, the end result is extremely readable and easily nested.


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (5)
collapsed Versions (5)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (5)Jan 18, 2012, 4:23:02 PM~Anita Froaploplen  
4Jan 18, 2012, 4:21:07 PM~George Chukiberg  
3Jan 18, 2012, 4:20:13 PM~George Chukiberg  
2Jan 18, 2012, 4:15:44 PM~George Chukiberg  
1Jan 18, 2012, 4:08:02 PM~George Chukiberg  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility